package karpiel.boguchwal.wojciech.przemek

import karpiel.boguchwal.wojciech.przemek.Ast.{Bruijn, PiValue, SumType, UnitType}
import org.scalatest.FunSuite

class UtilsTest extends FunSuite {

  import Utils._

  test("testUsesBruins") {
    assert(usesBruins(Bruijn(0)) == Set(0))
    assert(usesBruins(Bruijn(1)) == Set(1))
    assert(usesBruins(PiValue(UnitType, Bruijn(0))) == Set())
    assert(usesBruins(PiValue(UnitType, Bruijn(2))) == Set(1))
    assert(usesBruins(PiValue(UnitType, SumType(Bruijn(2), Bruijn(0)))) == Set(1))
    assert(usesBruins(PiValue(UnitType, SumType(Bruijn(2), Bruijn(4)))) == Set(1, 3))
    assert(usesBruins(PiValue(UnitType, SumType(PiValue(Bruijn(0), UnitType), Bruijn(4)))) == Set(3))
    assert(usesBruins(PiValue(UnitType, SumType(PiValue(Bruijn(0), Bruijn(5)), Bruijn(4)))) == Set(3))
  }

}
